import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    // 根目录就显示主页
    redirect: '/home/articles'
  },
  {
    path: '/home/:tab',
    name: 'home',
    component: () => import('./views/HomePage')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('./views/SearchPage'),
    children: [
      {
        path: '/search/users/:searchKey',
        name: 'users',
        component: () => import('./components/UserSearched')
      },
      {
        path: '/search/blogs/:searchKey',
        name: 'blogs',
        component: () => import('./components/BlogSearched')
      }
    ]
  },
  {
    path: '/chatHome',
    name: 'chatHome',
    component: () => import('./views/ChatHome')
  },
  {
    path: '/editArticle',
    name: 'articleEdit',
    component: () => import('./views/ArticleEdit')
  },
  {
    path: '/article/:id',
    name: 'articleDetail',
    component: () => import('./views/ArticleDetail')
  },
  {
    path: '/blogList/:searchKey',
    name: 'blogList',
    component: () => import('./views/BlogList')
  },
  {
    path: '/forbidden',
    name: 'forbidden',
    component: () => import('./views/ForbiddenPage')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: '/fxwy-home',
  routes
})

export default router
